We were updating the whole places sidebar when the trash changed.
This effectively removes all rows and create new ones for every trash
state change.
Although when using GtkTreeView it was somehow ok, with the new
implementation with GtkListBox this effectively locks the UI while the
trash operations are being performed.
When performing operations for i.e. 100 files, the UI can be locked
for more than 1 minute since gvfs-trash usually takes time.
To fix this just update the icon of the trash when the state of the
trash change instead of the whole sidebar.
https://bugzilla.gnome.org/show_bug.cgi?id=762677
gchar *rename_uri;
gulong trash_monitor_changed_id;
+ GtkWidget *trash_row;
/* DND */
GList *drag_list; /* list of GFile */
return is_external;
}
+static void
+update_trash_icon (GtkPlacesSidebar *sidebar)
+{
+ if (sidebar->trash_row)
+ gtk_sidebar_row_set_icon (GTK_SIDEBAR_ROW (sidebar->trash_row),
+ _gtk_trash_monitor_get_icon (sidebar->trash_monitor));
+}
+
static void
update_places (GtkPlacesSidebar *sidebar)
{
{
mount_uri = "trash:///"; /* No need to strdup */
icon = _gtk_trash_monitor_get_icon (sidebar->trash_monitor);
- add_place (sidebar, PLACES_BUILT_IN,
- SECTION_COMPUTER,
- _("Trash"), icon, mount_uri,
- NULL, NULL, NULL, 0,
- _("Open the trash"));
+ sidebar->trash_row = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
+ _("Trash"), icon, mount_uri,
+ NULL, NULL, NULL, 0,
+ _("Open the trash"));
g_object_unref (icon);
}
sidebar->trash_monitor = _gtk_trash_monitor_get ();
sidebar->trash_monitor_changed_id = g_signal_connect_swapped (sidebar->trash_monitor, "trash-state-changed",
- G_CALLBACK (update_places), sidebar);
+ G_CALLBACK (update_trash_icon), sidebar);
gtk_widget_set_size_request (GTK_WIDGET (sidebar), 140, 280);
break;
case PROP_ICON:
- g_set_object (&self->icon, g_value_get_object (value));
- if (self->icon != NULL)
- gtk_image_set_from_gicon (GTK_IMAGE (self->icon_widget), self->icon, GTK_ICON_SIZE_MENU);
- else
- gtk_image_clear (GTK_IMAGE (self->icon_widget));
+ gtk_sidebar_row_set_icon (self, g_value_get_object (value));
break;
case PROP_LABEL:
(GtkCallback) gtk_widget_destroy,
NULL);
- context = gtk_widget_get_style_context (GTK_WIDGET (self));
+ context = gtk_widget_get_style_context (GTK_WIDGET (self));
gtk_style_context_add_class (context, "sidebar-placeholder-row");
}
break;
gtk_revealer_set_transition_duration (GTK_REVEALER (self->revealer), transition_duration);
}
+void
+gtk_sidebar_row_set_icon (GtkSidebarRow *self,
+ GIcon *icon)
+{
+ g_return_if_fail (GTK_IS_SIDEBAR_ROW (self));
+
+ if (self->icon != icon)
+ {
+ g_set_object (&self->icon, icon);
+ if (self->icon != NULL)
+ gtk_image_set_from_gicon (GTK_IMAGE (self->icon_widget), self->icon,
+ GTK_ICON_SIZE_MENU);
+ else
+ gtk_image_clear (GTK_IMAGE (self->icon_widget));
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ICON]);
+ }
+}
+
static void
gtk_sidebar_row_finalize (GObject *object)
{
GtkWidget *gtk_sidebar_row_get_eject_button (GtkSidebarRow *self);
GtkWidget *gtk_sidebar_row_get_event_box (GtkSidebarRow *self);
+void gtk_sidebar_row_set_icon (GtkSidebarRow *self,
+ GIcon *icon);
G_END_DECLS